package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.api.content.model.vo.CourseBaseVO;
import com.xuecheng.content.entity.CourseBase;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface CourseBaseConvert {

    CourseBaseConvert INSTANCE = Mappers.getMapper(CourseBaseConvert.class);

    /**
     * PO与DTO映射转换
     *
     * @param courseBase 课程PO
     * @return {@link CourseBaseDTO 课程DTO}
     */
    @Mapping(source = "id", target = "courseBaseId")
    CourseBaseDTO entity2dto(CourseBase courseBase);

    /**
     * 集合数据转换
     * entity2dtos 依赖 entity2dto
     *
     * @param courseBase 课程PO
     * @return {@link List<CourseBaseDTO> 课程DTO集合}
     */
    List<CourseBaseDTO> entity2dtos(List<CourseBase> courseBase);

    /**
     * DTO与PO映射转换
     *
     * @param dto
     * @return
     */
    @Mapping(source = "courseBaseId", target = "id")
    CourseBase dto2entity(CourseBaseDTO dto);

    /**
     * VO与PO映射转换
     *
     * @param vo
     * @return
     */
    CourseBaseDTO vo2dto(CourseBaseVO vo);

    CourseBaseDTO audit2dto(CourseAuditVO auditVO);
}
